package com.eigland.eigaland_lib.base

import android.animation.Animator
import android.content.Context
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.annotation.IdRes
import androidx.fragment.app.Fragment
import com.eigland.eigaland_lib.R
import me.yokeyword.fragmentation.ExtraTransaction
import me.yokeyword.fragmentation.ISupportFragment
import me.yokeyword.fragmentation.SupportFragment
import me.yokeyword.fragmentation.SupportFragmentDelegate
import me.yokeyword.fragmentation.anim.FragmentAnimator

public abstract class BaseFragment :SupportFragment(){


    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
         return inflater.inflate(setLayoutId(),container,false)
     }

     override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        setUpViewData(view)

     }

    override fun onEnterAnimationEnd(savedInstanceState: Bundle?) {
        super.onEnterAnimationEnd(savedInstanceState)
        initVM()
    }


     fun goToNextFragment(cur:Fragment,next:Fragment,layoutId:Int){
        if(childFragmentManager.backStackEntryCount == 1) {
            childFragmentManager.beginTransaction().replace(layoutId,next).commit()
        } else {
            childFragmentManager.beginTransaction().add(layoutId,next).commit()
        }

     }

     /**
      * init your viewModel
      */
     abstract fun initVM()

     /**
      * set up view data
      */
     abstract fun setUpViewData(view:View)

     /**
      * set up layout Id
      */
     abstract fun setLayoutId():Int
}